library(dplyr)
#library(psych) #for pairs.panels, but could use other packages, e.g. GGalley
library(lavaan)
library(semPlot)
library(DiagrammeR)
library(ggplot2)
library(tidyr)
combined=read.csv("data/monthly_averages/monthly_data_compiled_regions.csv",stringsAsFactors = F)
cnames=read.csv("analysis/column_names_region_monthly.csv", stringsAsFactors = F)
dsub=filter(combined, Year>=1995) %>% arrange(Region,Year,Month)
focaldata=dsub[,cnames$Datacolumn]
fvars=cnames$Shortname
colnames(focaldata)=fvars
regions=unique(focaldata$region)
regionorder=c("Far West","West","North","South")
focaldata=focaldata%>%
mutate(decyear=year+(month-1)/12,
sinmon=sin(2*pi/12*month),
cosmon=cos(2*pi/12*month))
focaldata = focaldata %>%
mutate(tzoop=hcope+clad+mysid+pcope,
tzoop_c=hcope_c+clad_c+mysid_c+pcope_c,
tzoop_e=hcope_e+clad_e+mysid_e+pcope_e,
hzoop=hcope+clad,
hzoop_c=hcope_c+clad_c,
hzoop_e=hcope_e+clad_e,
pzoop=mysid+pcope,
pzoop_c=mysid_c+pcope_c,
pzoop_e=mysid_e+pcope_e)
fvars=c(fvars,"tzoop","tzoop_c","tzoop_e",
"hzoop","hzoop_c","hzoop_e",
"pzoop","pzoop_c","pzoop_e")
cnames=rbind(cnames,data.frame(Longname=NA,Shortname=c("tzoop","tzoop_c","tzoop_e",
"hzoop","hzoop_c","hzoop_e",
"pzoop","pzoop_c","pzoop_e"),
Diagramname=c("Total Zooplankton\nBiomass",
"Total Zooplankton\nAbundance",
"Total Zooplankton\nEnergy",
"Herbivorous Zooplankton\nBiomass",
"Herbivorous Zooplankton\nAbundance",
"Herbivorous Zooplankton\nEnergy",
"Predatory Zooplankton\nBiomass",
"Predatory Zooplankton\nAbundance",
"Predatory Zooplankton\nEnergy"),
Datacolumn=NA,Log="yes"))
#focal variables
varnames=c("temp","flow","nitrate","ammonia","dophos","din","chla","hcope","clad","amphi","pcope","mysid","potam","corbic","sside","cent","marfish_bsmt","estfish_bsmt","tzoop","tzoop_c","hzoop","pzoop")
#labels for lagged vars
cnameslag=cnames
cnameslag$Shortname=paste0(cnameslag$Shortname,"_1")
cnameslag$Diagramname=paste(cnameslag$Diagramname,"(t-1)")
cnameslag=rbind(cnames,cnameslag)
source("analysis/myLavaanPlot.r")
Notes:
Determine which vars are appropriate for which regions and at what lags.
Write out path diagram for each region.
Model with and without fish, probably, because of missing data.
Log transform, scale.
Within and across regions.
Create set with regional monthly means removed.
#log transform
logvars=fvars[cnames$Log=="yes"]
logtrans=function(x) {
x2=x[which(!is.na(x))]
if(any(x2==0)) {log(x+min(x2[which(x2>0)],na.rm=T))}
else {log(x)}
}
focaldatalog = focaldata %>%
mutate_at(logvars,logtrans)
#scale data
fdr0=focaldatalog
tvars=fvars[-(1:3)]
#scaled within regions
fdr=fdr0 %>%
group_by(region) %>%
#scale
mutate_at(tvars,scale) %>%
#lag
mutate_at(tvars,list("1"=lag,"2"=function(x) {lag(x,2)})) %>%
ungroup() %>%
as.data.frame()
#scaled within regions, remove monthly means
fdr_ds=fdr %>%
group_by(region,month) %>%
mutate_at(tvars,list("mm"=function(x) {mean(x,na.rm = T)})) %>%
mutate_at(tvars,function(x) {x-mean(x,na.rm = T)}) %>%
ungroup() %>%
#lag
group_by(region) %>%
mutate_at(tvars,list("1"=lag,"2"=function(x) {lag(x,2)})) %>%
ungroup() %>%
as.data.frame()
#scaled across regions
fdr1=fdr0 %>%
#scale
mutate_at(tvars,scale) %>%
#lag
group_by(region) %>%
mutate_at(tvars,list("1"=lag,"2"=function(x) {lag(x,2)})) %>%
ungroup() %>%
as.data.frame()
#scaled across regions, monthly means removed
fdr1_ds=fdr1 %>%
group_by(region,month) %>%
mutate_at(tvars,list("mm"=function(x) {mean(x,na.rm = T)})) %>%
mutate_at(tvars,function(x) {x-mean(x,na.rm = T)}) %>%
ungroup() %>%
#lag
group_by(region) %>%
mutate_at(tvars,list("1"=lag,"2"=function(x) {lag(x,2)})) %>%
ungroup() %>%
as.data.frame()
Data availability by series and region (prop zeros and prop missing)
FW: ignore clad, corbic, sside
W: ignore corbic, sside
S: ignore potam
dataavail=focaldata %>%
gather(var, value, 4:length(fvars)) %>%
group_by(region, var) %>%
summarize(
propmissing=length(which(is.na(value)))/length(value),
propzeros=length(which(value==0))/length(which(!is.na(value)))) %>%
as.data.frame()
#these variables should not be used (too many zeros)
filter(dataavail,propzeros>0.5 | is.na(propzeros))
## region var propmissing propzeros
## 1 Far West cent 1.0000000 NaN
## 2 Far West clad 0.1410256 0.9514925
## 3 Far West clad_c 0.1410256 0.9514925
## 4 Far West clad_e 0.1410256 0.9514925
## 5 Far West corbic 0.1410256 1.0000000
## 6 Far West marfish_bsot 0.4583333 0.6508876
## 7 Far West sbass_bsmt 0.4967949 0.7707006
## 8 Far West sbass_bsot 0.4583333 0.7218935
## 9 Far West smelt_bsmt 0.4967949 0.9808917
## 10 Far West smelt_bsot 0.4583333 0.9940828
## 11 Far West sside 1.0000000 NaN
## 12 North lfin_bsmt 0.5160256 0.8741722
## 13 North lfin_bsot 0.4711538 0.9393939
## 14 North marfish_bsmt 0.5160256 0.9735099
## 15 North marfish_bsot 0.4711538 0.9939394
## 16 North sbass_bsmt 0.5160256 0.5496689
## 17 North smelt_bsot 0.4711538 0.8242424
## 18 South lfin_bsmt 0.5128205 1.0000000
## 19 South lfin_bsot 0.4679487 1.0000000
## 20 South marfish_bsmt 0.5128205 1.0000000
## 21 South marfish_bsot 0.4679487 1.0000000
## 22 South potam 0.1378205 0.9702602
## 23 South sbass_bsmt 0.5128205 0.6513158
## 24 South smelt_bsmt 0.5128205 0.8486842
## 25 South smelt_bsot 0.4679487 0.9156627
## 26 West cent 1.0000000 NaN
## 27 West corbic 0.1378205 0.8066914
## 28 West marfish_bsot 0.4615385 0.9047619
## 29 West smelt_bsmt 0.5000000 0.5128205
## 30 West smelt_bsot 0.4615385 0.7619048
## 31 West sside 1.0000000 NaN
#these variables have lots of missing data
filter(dataavail,propmissing>0.45 | is.na(propmissing))
## region var propmissing propzeros
## 1 Far West cent 1.0000000 NaN
## 2 Far West estfish_bsmt 0.4967949 0.165605096
## 3 Far West estfish_bsot 0.4583333 0.201183432
## 4 Far West lfin_bsmt 0.4967949 0.356687898
## 5 Far West lfin_bsot 0.4583333 0.248520710
## 6 Far West marfish_bsmt 0.4967949 0.006369427
## 7 Far West marfish_bsot 0.4583333 0.650887574
## 8 Far West sbass_bsmt 0.4967949 0.770700637
## 9 Far West sbass_bsot 0.4583333 0.721893491
## 10 Far West smelt_bsmt 0.4967949 0.980891720
## 11 Far West smelt_bsot 0.4583333 0.994082840
## 12 Far West sside 1.0000000 NaN
## 13 North estfish_bsmt 0.5160256 0.152317881
## 14 North estfish_bsot 0.4711538 0.236363636
## 15 North lfin_bsmt 0.5160256 0.874172185
## 16 North lfin_bsot 0.4711538 0.939393939
## 17 North marfish_bsmt 0.5160256 0.973509934
## 18 North marfish_bsot 0.4711538 0.993939394
## 19 North sbass_bsmt 0.5160256 0.549668874
## 20 North sbass_bsot 0.4711538 0.260606061
## 21 North smelt_bsmt 0.5160256 0.403973510
## 22 North smelt_bsot 0.4711538 0.824242424
## 23 South estfish_bsmt 0.5128205 0.197368421
## 24 South estfish_bsot 0.4679487 0.180722892
## 25 South lfin_bsmt 0.5128205 1.000000000
## 26 South lfin_bsot 0.4679487 1.000000000
## 27 South marfish_bsmt 0.5128205 1.000000000
## 28 South marfish_bsot 0.4679487 1.000000000
## 29 South sbass_bsmt 0.5128205 0.651315789
## 30 South sbass_bsot 0.4679487 0.204819277
## 31 South smelt_bsmt 0.5128205 0.848684211
## 32 South smelt_bsot 0.4679487 0.915662651
## 33 West cent 1.0000000 NaN
## 34 West estfish_bsmt 0.5000000 0.019230769
## 35 West estfish_bsot 0.4615385 0.077380952
## 36 West lfin_bsmt 0.5000000 0.250000000
## 37 West lfin_bsot 0.4615385 0.392857143
## 38 West marfish_bsmt 0.5000000 0.115384615
## 39 West marfish_bsot 0.4615385 0.904761905
## 40 West sbass_bsmt 0.5000000 0.294871795
## 41 West sbass_bsot 0.4615385 0.184523810
## 42 West smelt_bsmt 0.5000000 0.512820513
## 43 West smelt_bsot 0.4615385 0.761904762
## 44 West sside 1.0000000 NaN
(only sig correlations shown… no correction for multiple comparisons)
Other notes:
Detrended fish indices are NOT correlated in S!
Nitrate and ammonia are positively correlated, max at lag 0 all regions.
Nitrate and dophos are positively correlated, max at lag 0 all regions.
Ammonia and dophos are positively correlated, lag 0 for FW and S, ammonia lags dphos by 3 months in W and N.
Chla nitrate neg correlated, lag 0.
Chla ammonia neg correlated, lag 0.
Chla dophos relationship unclear.
High flow 2-4 month prev = high chla
Hcope lags chla by 1, positive, except FW.
Clad seem to precede chla by 2, positive.
Amphi relationship unclear, prob bc not eating chla in water column.
In N and W, chla lags potam, negative. The opposite in W.
Mysid and hcope postive, lag 0.
In S and W, hcope lags pcope, negative.
This doesn’t consider time lags.
l_modelsfw = data.frame(l_model = c("tzoop","tzoop_c",
"hzoop","hzoop+pzoop","pzoop",
"hcope","amphi","pcope",
"tzoop+amphi","hzoop+amphi","pzoop+amphi",
"hcope+pcope","hcope+amphi","pcope+amphi",
"hcope+pcope+amphi"))
l_models = data.frame(l_model = c("tzoop","tzoop_c",
"hzoop","hzoop+pzoop","pzoop",
"mysid","hcope","clad","amphi","pcope",
"tzoop+amphi","hzoop+amphi","pzoop+amphi","pzoop+clad",
"hzoop+mysid","pzoop+clad+hcope",
"hcope+pcope","hcope+amphi","pcope+amphi","hcope+clad",
"amphi+clad","pcope+clad","mysid+amphi",
"hcope+clad+mysid",
"hcope+clad+mysid+pcope",
"hcope+mysid",
"hcope+mysid+pcope",
"hcope+mysid+amphi"))
l_modelss = data.frame(l_model = c("tzoop","tzoop_c",
"hzoop","hzoop+pzoop","pzoop",
"hcope","amphi","pcope","clad",
"tzoop+amphi","hzoop+amphi","pzoop+amphi","pzoop+clad",
"pzoop+clad+hcope",
"hcope+pcope","hcope+amphi","pcope+amphi","hcope+clad",
"amphi+clad","pcope+clad",
"hcope+pcope+amphi","hcope+pcope+clad",
"hcope+pcope+amphi+clad"))
#Midwater Trawl
fwestmods = purrr::map(l_modelsfw$l_model, ~lm(paste0("estfish_bsmt ~", .x),
data = filter(fdr_ds,region=="Far West" & !is.na(amphi) & !is.na(tzoop))))
names(fwestmods)=l_modelsfw$l_model
bbmle::AICctab(fwestmods,weights=T,delta=T)
## dAICc df weight
## hcope+pcope+amphi 0.0 5 0.5632
## hzoop+amphi 1.8 4 0.2284
## hcope+amphi 3.3 4 0.1060
## pcope+amphi 5.5 4 0.0355
## tzoop+amphi 6.6 4 0.0212
## amphi 7.7 3 0.0121
## pzoop+amphi 8.0 4 0.0106
## hzoop 8.1 3 0.0096
## hcope 9.6 3 0.0047
## hcope+pcope 9.8 4 0.0043
## hzoop+pzoop 10.2 4 0.0034
## tzoop 14.1 3 <0.001
## pcope 15.6 3 <0.001
## tzoop_c 16.4 3 <0.001
## pzoop 16.6 3 <0.001
westmods = purrr::map(l_models$l_model, ~lm(paste0("estfish_bsmt ~", .x),
data = filter(fdr_ds,region=="West" & !is.na(amphi) & !is.na(tzoop))))
names(westmods)=l_models$l_model
bbmle::AICctab(westmods,weights=T,delta=T)
## dAICc df weight
## mysid+amphi 0.0 4 0.3392
## pzoop+amphi 2.0 4 0.1273
## hcope+mysid+amphi 2.0 5 0.1244
## amphi+clad 2.2 4 0.1137
## amphi 2.6 3 0.0941
## tzoop+amphi 3.9 4 0.0489
## pcope+amphi 3.9 4 0.0481
## hcope+amphi 4.5 4 0.0353
## hzoop+amphi 4.6 4 0.0332
## hcope+clad+mysid+pcope 6.4 6 0.0141
## hcope+mysid+pcope 7.9 5 0.0065
## mysid 8.5 3 0.0049
## pcope+clad 9.9 4 0.0023
## hzoop+mysid 10.4 4 0.0019
## hcope+mysid 10.5 4 0.0018
## hcope+clad+mysid 10.7 5 0.0016
## pcope 13.2 3 <0.001
## pzoop+clad 13.6 4 <0.001
## clad 13.6 3 <0.001
## pzoop 13.7 3 <0.001
## hcope+clad 14.4 4 <0.001
## hcope+pcope 14.5 4 <0.001
## pzoop+clad+hcope 15.3 5 <0.001
## tzoop 15.7 3 <0.001
## hzoop+pzoop 15.8 4 <0.001
## hcope 16.4 3 <0.001
## hzoop 16.7 3 <0.001
## tzoop_c 16.7 3 <0.001
northmods = purrr::map(l_models$l_model, ~lm(paste0("estfish_bsmt ~", .x),
data = filter(fdr_ds,region=="North" & !is.na(amphi) & !is.na(tzoop))))
names(northmods)=l_models$l_model
bbmle::AICctab(northmods,weights=T,delta=T)
## dAICc df weight
## tzoop_c 0.0 3 0.1695
## hcope+mysid 1.5 4 0.0802
## mysid 1.5 3 0.0787
## hcope 1.8 3 0.0678
## hcope+mysid+amphi 1.9 5 0.0654
## mysid+amphi 2.0 4 0.0631
## hcope+amphi 2.4 4 0.0521
## hcope+mysid+pcope 2.5 5 0.0484
## pzoop+clad+hcope 2.6 5 0.0455
## hcope+pcope 2.7 4 0.0449
## tzoop 2.8 3 0.0426
## hcope+clad 2.9 4 0.0403
## tzoop+amphi 3.1 4 0.0365
## hcope+clad+mysid 3.1 5 0.0359
## hzoop+mysid 3.4 4 0.0310
## hcope+clad+mysid+pcope 4.3 6 0.0202
## pzoop+amphi 4.3 4 0.0201
## pzoop 4.6 3 0.0171
## hzoop+pzoop 4.9 4 0.0148
## pzoop+clad 5.5 4 0.0110
## hzoop 7.0 3 0.0051
## hzoop+amphi 7.7 4 0.0036
## amphi+clad 9.1 4 0.0018
## clad 9.2 3 0.0017
## pcope+clad 10.0 4 0.0012
## pcope 11.2 3 <0.001
## pcope+amphi 11.4 4 <0.001
## amphi 11.8 3 <0.001
southmods = purrr::map(l_modelss$l_model, ~lm(paste0("estfish_bsmt ~", .x),
data = filter(fdr_ds,region=="South" & !is.na(amphi) & !is.na(tzoop))))
names(southmods)=l_modelss$l_model
bbmle::AICctab(southmods,weights=T,delta=T)
## dAICc df weight
## pzoop+clad 0.0 4 0.2663
## hzoop+pzoop 0.1 4 0.2499
## pzoop+clad+hcope 0.2 5 0.2356
## pzoop 1.1 3 0.1518
## pzoop+amphi 3.3 4 0.0524
## hcope 7.6 3 0.0058
## tzoop_c 8.0 3 0.0050
## hzoop 8.0 3 0.0049
## tzoop 8.3 3 0.0041
## clad 8.7 3 0.0034
## pcope 9.2 3 0.0027
## amphi 9.2 3 0.0026
## hcope+clad 9.4 4 0.0024
## hcope+pcope 9.6 4 0.0022
## hcope+amphi 9.7 4 0.0021
## hzoop+amphi 10.1 4 0.0017
## tzoop+amphi 10.4 4 0.0015
## pcope+clad 10.4 4 0.0014
## amphi+clad 10.8 4 0.0012
## hcope+pcope+clad 11.2 5 <0.001
## pcope+amphi 11.2 4 <0.001
## hcope+pcope+amphi 11.7 5 <0.001
## hcope+pcope+amphi+clad 13.4 6 <0.001
Unlike annual model, individual zooplankton groups seems to be better predictors. The sign is not always what you would expect though.
l_modelsfw = data.frame(l_model = c("hcope+pcope+amphi",
"hcope+pcope+amphi+marfish_bsmt"))
l_modelsw = data.frame(l_model = c("mysid+amphi",
"mysid+amphi+marfish_bsmt"))
l_modelsn = data.frame(l_model = c("hcope+mysid",
"hcope+mysid+sside"))
l_modelss = data.frame(l_model = c("pzoop+clad+hcope",
"pzoop+clad+hcope+sside"))
#Midwater Trawl
fwestmods = purrr::map(l_modelsfw$l_model, ~lm(paste0("estfish_bsmt ~", .x),
data = filter(fdr_ds,region=="Far West" & !is.na(amphi))))
names(fwestmods)=l_modelsfw$l_model
bbmle::AICctab(fwestmods,weights=T,delta=T)
## dAICc df weight
## hcope+pcope+amphi+marfish_bsmt 0.0 6 0.904
## hcope+pcope+amphi 4.5 5 0.096
westmods = purrr::map(l_modelsw$l_model, ~lm(paste0("estfish_bsmt ~", .x),
data = filter(fdr_ds,region=="West" & !is.na(amphi))))
names(westmods)=l_modelsw$l_model
bbmle::AICctab(westmods,weights=T,delta=T)
## dAICc df weight
## mysid+amphi 0.0 4 0.73
## mysid+amphi+marfish_bsmt 2.0 5 0.27
northmods = purrr::map(l_modelsn$l_model, ~lm(paste0("estfish_bsmt ~", .x),
data = filter(fdr_ds,region=="North" & !is.na(sside))))
names(northmods)=l_modelsn$l_model
bbmle::AICctab(northmods,weights=T,delta=T)
## dAICc df weight
## hcope+mysid 0.0 4 0.72
## hcope+mysid+sside 1.9 5 0.28
southmods = purrr::map(l_modelss$l_model, ~lm(paste0("estfish_bsmt ~", .x),
data = filter(fdr_ds,region=="South" & !is.na(sside))))
names(southmods)=l_modelss$l_model
bbmle::AICctab(southmods,weights=T,delta=T)
## dAICc df weight
## pzoop+clad+hcope 0.0 5 0.75
## pzoop+clad+hcope+sside 2.1 6 0.25
Marine fishes important in FW but not W. Silversides not important in N and S.
This model does not use time lags.
modFW='chla~potam+flow+temp+secchi
hcope~chla+potam+flow+temp+secchi
pcope~chla+potam+flow+temp+secchi
amphi~chla+potam+flow+temp+secchi
estfish_bsmt~hcope+pcope+amphi+flow+temp+secchi+marfish_bsmt
marfish_bsmt~flow
amphi~~hcope+pcope
hcope~~pcope
'
modW='chla~potam+flow+temp+secchi
mysid~chla+potam+flow+temp+secchi
amphi~chla+potam+flow+temp+secchi
estfish_bsmt~mysid+amphi+flow+temp+secchi
amphi~~mysid
'
modN='chla~corbic+flow+temp+secchi
mysid~chla+corbic+flow+temp+secchi
hcope~chla+corbic+flow+temp+secchi
estfish_bsmt~mysid+hcope+flow+temp+secchi
hcope~~mysid
'
modS='chla~corbic+flow+temp+secchi
clad~chla+corbic+flow+temp+secchi
hcope~chla+corbic+flow+temp+secchi
pzoop~chla+corbic+flow+temp+secchi
estfish_bsmt~pzoop+clad+hcope+flow+temp+secchi
hcope~~pzoop+clad
pzoop~~clad
'
modfitFW=sem(modFW, data=filter(fdr_ds,region=="Far West"))
modfitW=sem(modW, data=filter(fdr_ds,region=="West"))
modfitN=sem(modN, data=filter(fdr_ds,region=="North"))
modfitS=sem(modS, data=filter(fdr_ds,region=="South"))
summary(modfitFW, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 36 iterations
##
## Optimization method NLMINB
## Number of free parameters 36
##
## Used Total
## Number of observations 126 312
##
## Estimator ML
## Model Fit Test Statistic 10.254
## Degrees of freedom 9
## P-value (Chi-square) 0.330
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## potam 0.047 0.049 0.963 0.335 0.047 0.086
## flow 0.106 0.125 0.844 0.398 0.106 0.078
## temp 0.268 0.208 1.286 0.199 0.268 0.116
## secchi 0.087 0.084 1.044 0.296 0.087 0.097
## hcope ~
## chla 0.001 0.133 0.011 0.991 0.001 0.001
## potam -0.091 0.073 -1.238 0.216 -0.091 -0.110
## flow -0.041 0.187 -0.220 0.826 -0.041 -0.020
## temp 0.480 0.312 1.540 0.124 0.480 0.139
## secchi -0.022 0.125 -0.172 0.863 -0.022 -0.016
## pcope ~
## chla 0.012 0.084 0.149 0.881 0.012 0.013
## potam -0.094 0.046 -2.034 0.042 -0.094 -0.176
## flow 0.258 0.118 2.184 0.029 0.258 0.197
## temp 0.299 0.197 1.516 0.130 0.299 0.133
## secchi -0.064 0.079 -0.810 0.418 -0.064 -0.073
## amphi ~
## chla -0.048 0.097 -0.498 0.618 -0.048 -0.035
## potam -0.019 0.053 -0.354 0.723 -0.019 -0.025
## flow -0.946 0.136 -6.934 0.000 -0.946 -0.509
## temp -0.013 0.227 -0.056 0.955 -0.013 -0.004
## secchi 0.300 0.091 3.290 0.001 0.300 0.242
## estfish_bsmt ~
## hcope -0.155 0.065 -2.372 0.018 -0.155 -0.182
## pcope -0.170 0.104 -1.625 0.104 -0.170 -0.129
## amphi -0.110 0.091 -1.206 0.228 -0.110 -0.119
## flow 0.368 0.166 2.217 0.027 0.368 0.215
## temp -0.622 0.231 -2.696 0.007 -0.622 -0.211
## secchi -0.192 0.094 -2.037 0.042 -0.192 -0.168
## marfish_bsmt 0.328 0.099 3.321 0.001 0.328 0.263
## marfish_bsmt ~
## flow -0.433 0.116 -3.729 0.000 -0.433 -0.315
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .hcope ~~
## .amphi 0.049 0.073 0.666 0.505 0.049 0.059
## .pcope ~~
## .amphi -0.118 0.048 -2.486 0.013 -0.118 -0.227
## .hcope ~~
## .pcope -0.103 0.064 -1.598 0.110 -0.103 -0.144
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.510 0.064 7.937 0.000 0.510 0.971
## .hcope 1.128 0.142 7.937 0.000 1.128 0.964
## .pcope 0.450 0.057 7.937 0.000 0.450 0.913
## .amphi 0.600 0.076 7.937 0.000 0.600 0.604
## .estfish_bsmt 0.601 0.076 7.937 0.000 0.601 0.710
## .marfish_bsmt 0.489 0.062 7.937 0.000 0.489 0.901
##
## R-Square:
## Estimate
## chla 0.029
## hcope 0.036
## pcope 0.087
## amphi 0.396
## estfish_bsmt 0.290
## marfish_bsmt 0.099
summary(modfitW, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 34 iterations
##
## Optimization method NLMINB
## Number of free parameters 24
##
## Used Total
## Number of observations 134 312
##
## Estimator ML
## Model Fit Test Statistic 1.735
## Degrees of freedom 2
## P-value (Chi-square) 0.420
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## potam 0.032 0.080 0.407 0.684 0.032 0.039
## flow 0.301 0.130 2.317 0.021 0.301 0.205
## temp -0.299 0.251 -1.192 0.233 -0.299 -0.105
## secchi -0.047 0.091 -0.519 0.604 -0.047 -0.050
## mysid ~
## chla 0.102 0.082 1.254 0.210 0.102 0.097
## potam -0.163 0.075 -2.156 0.031 -0.163 -0.186
## flow -0.314 0.125 -2.519 0.012 -0.314 -0.203
## temp 0.419 0.238 1.761 0.078 0.419 0.139
## secchi -0.371 0.086 -4.326 0.000 -0.371 -0.373
## amphi ~
## chla 0.267 0.106 2.523 0.012 0.267 0.194
## potam 0.310 0.098 3.170 0.002 0.310 0.273
## flow 0.212 0.162 1.311 0.190 0.212 0.105
## temp -0.365 0.309 -1.182 0.237 -0.365 -0.093
## secchi 0.375 0.111 3.371 0.001 0.375 0.290
## estfish_bsmt ~
## mysid 0.121 0.093 1.297 0.195 0.121 0.113
## amphi -0.195 0.069 -2.814 0.005 -0.195 -0.236
## flow -0.459 0.131 -3.504 0.000 -0.459 -0.276
## temp -0.189 0.265 -0.712 0.477 -0.189 -0.058
## secchi -0.104 0.100 -1.034 0.301 -0.104 -0.097
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .mysid ~~
## .amphi -0.034 0.056 -0.611 0.541 -0.034 -0.053
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.560 0.068 8.185 0.000 0.560 0.940
## .mysid 0.499 0.061 8.185 0.000 0.499 0.749
## .amphi 0.839 0.102 8.185 0.000 0.839 0.746
## .estfish_bsmt 0.606 0.074 8.185 0.000 0.606 0.789
##
## R-Square:
## Estimate
## chla 0.060
## mysid 0.251
## amphi 0.254
## estfish_bsmt 0.211
summary(modfitN, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 36 iterations
##
## Optimization method NLMINB
## Number of free parameters 24
##
## Used Total
## Number of observations 129 312
##
## Estimator ML
## Model Fit Test Statistic 1.166
## Degrees of freedom 2
## P-value (Chi-square) 0.558
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## corbic -0.111 0.064 -1.747 0.081 -0.111 -0.150
## flow -0.092 0.138 -0.668 0.504 -0.092 -0.060
## temp 0.262 0.225 1.165 0.244 0.262 0.103
## secchi -0.095 0.068 -1.402 0.161 -0.095 -0.123
## mysid ~
## chla -0.012 0.076 -0.158 0.874 -0.012 -0.011
## corbic -0.093 0.056 -1.676 0.094 -0.093 -0.118
## flow -0.429 0.120 -3.575 0.000 -0.429 -0.260
## temp 0.399 0.196 2.035 0.042 0.399 0.146
## secchi -0.368 0.059 -6.233 0.000 -0.368 -0.443
## hcope ~
## chla -0.123 0.052 -2.381 0.017 -0.123 -0.164
## corbic 0.006 0.038 0.146 0.884 0.006 0.010
## flow -0.473 0.081 -5.831 0.000 -0.473 -0.412
## temp 0.469 0.133 3.534 0.000 0.469 0.246
## secchi -0.183 0.040 -4.578 0.000 -0.183 -0.316
## estfish_bsmt ~
## mysid 0.102 0.099 1.025 0.306 0.102 0.122
## hcope 0.019 0.145 0.135 0.893 0.019 0.016
## flow -0.391 0.130 -3.006 0.003 -0.391 -0.285
## temp -0.016 0.197 -0.080 0.936 -0.016 -0.007
## secchi -0.068 0.065 -1.034 0.301 -0.068 -0.098
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .mysid ~~
## .hcope 0.132 0.024 5.383 0.000 0.132 0.538
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.483 0.060 8.031 0.000 0.483 0.931
## .mysid 0.362 0.045 8.031 0.000 0.362 0.605
## .hcope 0.166 0.021 8.031 0.000 0.166 0.572
## .estfish_bsmt 0.343 0.043 8.031 0.000 0.343 0.835
##
## R-Square:
## Estimate
## chla 0.069
## mysid 0.395
## hcope 0.428
## estfish_bsmt 0.165
summary(modfitS, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 42 iterations
##
## Optimization method NLMINB
## Number of free parameters 33
##
## Used Total
## Number of observations 131 312
##
## Estimator ML
## Model Fit Test Statistic 0.128
## Degrees of freedom 2
## P-value (Chi-square) 0.938
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## corbic -0.039 0.068 -0.572 0.567 -0.039 -0.050
## flow -0.163 0.105 -1.559 0.119 -0.163 -0.134
## temp 0.405 0.288 1.408 0.159 0.405 0.120
## secchi -0.145 0.089 -1.623 0.105 -0.145 -0.139
## clad ~
## chla 0.421 0.075 5.632 0.000 0.421 0.416
## corbic 0.102 0.058 1.752 0.080 0.102 0.129
## flow 0.195 0.090 2.158 0.031 0.195 0.159
## temp 0.496 0.248 2.001 0.045 0.496 0.146
## secchi 0.421 0.077 5.456 0.000 0.421 0.400
## hcope ~
## chla -0.017 0.043 -0.399 0.690 -0.017 -0.032
## corbic 0.059 0.034 1.761 0.078 0.059 0.141
## flow -0.238 0.052 -4.555 0.000 -0.238 -0.364
## temp 0.389 0.143 2.715 0.007 0.389 0.215
## secchi -0.039 0.045 -0.864 0.387 -0.039 -0.069
## pzoop ~
## chla 0.235 0.077 3.053 0.002 0.235 0.261
## corbic 0.046 0.060 0.768 0.443 0.046 0.065
## flow -0.083 0.093 -0.893 0.372 -0.083 -0.076
## temp 0.060 0.256 0.235 0.814 0.060 0.020
## secchi -0.071 0.080 -0.893 0.372 -0.071 -0.076
## estfish_bsmt ~
## pzoop 0.194 0.074 2.625 0.009 0.194 0.232
## clad -0.019 0.072 -0.261 0.794 -0.019 -0.025
## hcope -0.272 0.127 -2.145 0.032 -0.272 -0.195
## flow -0.097 0.081 -1.189 0.235 -0.097 -0.106
## temp 0.107 0.213 0.503 0.615 0.107 0.042
## secchi -0.193 0.070 -2.755 0.006 -0.193 -0.246
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .hcope ~~
## .pzoop 0.007 0.026 0.272 0.786 0.007 0.024
## .clad ~~
## .hcope 0.063 0.026 2.457 0.014 0.063 0.220
## .pzoop 0.157 0.047 3.359 0.001 0.157 0.307
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.678 0.084 8.093 0.000 0.678 0.942
## .clad 0.495 0.061 8.093 0.000 0.495 0.674
## .hcope 0.166 0.020 8.093 0.000 0.166 0.798
## .pzoop 0.526 0.065 8.093 0.000 0.526 0.904
## .estfish_bsmt 0.343 0.042 8.093 0.000 0.343 0.846
##
## R-Square:
## Estimate
## chla 0.058
## clad 0.326
## hcope 0.202
## pzoop 0.096
## estfish_bsmt 0.154
#modificationindices(modfitW)
labelsfarwest=createLabels(modfitFW, cnameslag)
labelswest=createLabels(modfitW, cnameslag)
labelsnorth=createLabels(modfitN, cnameslag)
labelssouth=createLabels(modfitS, cnameslag)
#FAR WEST
myLavaanPlot(model=modfitFW, labels=labelsfarwest,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
#WEST
myLavaanPlot(model=modfitW, labels=labelswest,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
#NORTH
myLavaanPlot(model=modfitN, labels=labelsnorth,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
#SOUTH
myLavaanPlot(model=modfitS, labels=labelssouth,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
modFW='chla~chla_1+hzoop_1+potam_1+flow+temp+secchi
hzoop~chla_1+hzoop_1+pzoop_1+potam_1+estfish_bsmt_1+flow+temp+secchi
pzoop~hzoop_1+pzoop_1+potam_1+estfish_bsmt_1+flow+temp+secchi
estfish_bsmt~hzoop_1+pzoop_1+estfish_bsmt_1+flow+temp+secchi+marfish_bsmt_1
'
modW='chla~chla_1+hzoop_1+potam_1+flow+temp+secchi
hzoop~chla_1+hzoop_1+pzoop_1+potam_1+estfish_bsmt_1+flow+temp+secchi
pzoop~chla_1+hzoop_1+pzoop_1+potam_1+estfish_bsmt_1+flow+temp+secchi
estfish_bsmt~hzoop_1+pzoop_1+estfish_bsmt_1+flow+temp+secchi+marfish_bsmt_1
'
modN='chla~chla_1+hzoop_1+corbic_1+flow+temp+secchi
hzoop~chla_1+hzoop_1+pzoop_1+corbic_1+estfish_bsmt_1+flow+temp+secchi
pzoop~chla_1+hzoop_1+pzoop_1+corbic_1+estfish_bsmt_1+flow+temp+secchi
estfish_bsmt~hzoop_1+pzoop_1+estfish_bsmt_1+flow+temp+secchi+sside_1+cent_1
'
modS='chla~chla_1+hzoop_1+corbic_1+estfish_bsmt_1+flow+temp+secchi
hzoop~chla_1+hzoop_1+pzoop_1+corbic_1+estfish_bsmt_1+flow+temp+secchi
pzoop~chla_1+hzoop_1+pzoop_1+corbic_1+estfish_bsmt_1+flow+temp+secchi
estfish_bsmt~chla_1+hzoop_1+pzoop_1+estfish_bsmt_1+flow+temp+secchi+sside_1+cent_1
'
modfitFW=sem(modFW, data=filter(fdr_ds,region=="Far West"))
modfitW=sem(modW, data=filter(fdr_ds,region=="West"))
modfitN=sem(modN, data=filter(fdr_ds,region=="North"))
modfitS=sem(modS, data=filter(fdr_ds,region=="South"))
summary(modfitFW, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 38 iterations
##
## Optimization method NLMINB
## Number of free parameters 38
##
## Used Total
## Number of observations 100 312
##
## Estimator ML
## Model Fit Test Statistic 12.443
## Degrees of freedom 8
## P-value (Chi-square) 0.133
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## chla_1 0.257 0.091 2.837 0.005 0.257 0.265
## hzoop_1 0.045 0.065 0.693 0.489 0.045 0.065
## potam_1 0.034 0.054 0.620 0.535 0.034 0.057
## flow 0.308 0.212 1.454 0.146 0.308 0.142
## temp 0.448 0.228 1.969 0.049 0.448 0.187
## secchi 0.090 0.091 0.993 0.321 0.090 0.098
## hzoop ~
## chla_1 0.291 0.124 2.343 0.019 0.291 0.202
## hzoop_1 0.388 0.092 4.226 0.000 0.388 0.381
## pzoop_1 0.034 0.106 0.323 0.747 0.034 0.030
## potam_1 -0.165 0.075 -2.187 0.029 -0.165 -0.188
## estfish_bsmt_1 -0.139 0.117 -1.191 0.234 -0.139 -0.114
## flow -0.172 0.319 -0.541 0.589 -0.172 -0.054
## temp -0.212 0.318 -0.666 0.505 -0.212 -0.060
## secchi -0.100 0.126 -0.796 0.426 -0.100 -0.073
## pzoop ~
## hzoop_1 -0.028 0.074 -0.375 0.707 -0.028 -0.035
## pzoop_1 0.216 0.086 2.523 0.012 0.216 0.244
## potam_1 -0.178 0.061 -2.895 0.004 -0.178 -0.263
## estfish_bsmt_1 0.039 0.094 0.418 0.676 0.039 0.042
## flow 0.118 0.253 0.467 0.640 0.118 0.048
## temp 0.103 0.256 0.404 0.687 0.103 0.038
## secchi -0.237 0.100 -2.362 0.018 -0.237 -0.226
## estfish_bsmt ~
## hzoop_1 -0.146 0.075 -1.958 0.050 -0.146 -0.171
## pzoop_1 0.195 0.087 2.223 0.026 0.195 0.202
## estfish_bsmt_1 0.331 0.094 3.521 0.000 0.331 0.324
## flow 0.170 0.266 0.636 0.525 0.170 0.063
## temp -0.368 0.258 -1.425 0.154 -0.368 -0.124
## secchi -0.188 0.101 -1.865 0.062 -0.188 -0.164
## marfish_bsmt_1 0.040 0.139 0.286 0.775 0.040 0.026
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla ~~
## .hzoop -0.026 0.060 -0.423 0.672 -0.026 -0.042
## .pzoop 0.029 0.049 0.603 0.546 0.029 0.060
## .estfish_bsmt -0.052 0.049 -1.056 0.291 -0.052 -0.106
## .hzoop ~~
## .pzoop -0.033 0.067 -0.499 0.618 -0.033 -0.050
## .estfish_bsmt -0.104 0.068 -1.537 0.124 -0.104 -0.156
## .pzoop ~~
## .estfish_bsmt -0.030 0.054 -0.549 0.583 -0.030 -0.055
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.438 0.062 7.071 0.000 0.438 0.833
## .hzoop 0.828 0.117 7.071 0.000 0.828 0.718
## .pzoop 0.540 0.076 7.071 0.000 0.540 0.785
## .estfish_bsmt 0.541 0.076 7.071 0.000 0.541 0.664
##
## R-Square:
## Estimate
## chla 0.167
## hzoop 0.282
## pzoop 0.215
## estfish_bsmt 0.336
summary(modfitW, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 40 iterations
##
## Optimization method NLMINB
## Number of free parameters 39
##
## Used Total
## Number of observations 107 312
##
## Estimator ML
## Model Fit Test Statistic 10.742
## Degrees of freedom 7
## P-value (Chi-square) 0.150
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## chla_1 0.233 0.085 2.753 0.006 0.233 0.263
## hzoop_1 -0.106 0.092 -1.147 0.251 -0.106 -0.114
## potam_1 0.013 0.087 0.152 0.879 0.013 0.016
## flow 0.510 0.212 2.404 0.016 0.510 0.226
## temp -0.409 0.263 -1.553 0.120 -0.409 -0.147
## secchi -0.049 0.092 -0.534 0.593 -0.049 -0.057
## hzoop ~
## chla_1 0.104 0.078 1.332 0.183 0.104 0.113
## hzoop_1 0.179 0.092 1.938 0.053 0.179 0.184
## pzoop_1 0.093 0.084 1.106 0.269 0.093 0.094
## potam_1 -0.143 0.082 -1.742 0.082 -0.143 -0.165
## estfish_bsmt_1 0.141 0.076 1.855 0.064 0.141 0.161
## flow 0.856 0.214 4.006 0.000 0.856 0.365
## temp 0.380 0.243 1.562 0.118 0.380 0.132
## secchi -0.060 0.085 -0.711 0.477 -0.060 -0.067
## pzoop ~
## chla_1 0.215 0.069 3.128 0.002 0.215 0.276
## hzoop_1 -0.007 0.083 -0.090 0.928 -0.007 -0.009
## pzoop_1 0.341 0.076 4.482 0.000 0.341 0.409
## potam_1 0.007 0.072 0.099 0.921 0.007 0.010
## estfish_bsmt_1 0.002 0.069 0.030 0.976 0.002 0.003
## flow -0.062 0.192 -0.326 0.744 -0.062 -0.032
## temp 0.397 0.218 1.820 0.069 0.397 0.163
## secchi -0.068 0.076 -0.894 0.371 -0.068 -0.090
## estfish_bsmt ~
## hzoop_1 0.108 0.115 0.938 0.348 0.108 0.102
## pzoop_1 -0.162 0.110 -1.476 0.140 -0.162 -0.151
## estfish_bsmt_1 0.232 0.095 2.439 0.015 0.232 0.243
## flow -0.128 0.262 -0.490 0.624 -0.128 -0.050
## temp -0.029 0.297 -0.097 0.923 -0.029 -0.009
## secchi -0.133 0.099 -1.353 0.176 -0.133 -0.137
## marfish_bsmt_1 0.129 0.101 1.272 0.203 0.129 0.126
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla ~~
## .hzoop 0.073 0.041 1.785 0.074 0.073 0.175
## .pzoop 0.028 0.036 0.782 0.434 0.028 0.076
## .estfish_bsmt 0.001 0.051 0.023 0.982 0.001 0.002
## .hzoop ~~
## .pzoop 0.055 0.034 1.643 0.100 0.055 0.161
## .estfish_bsmt -0.002 0.047 -0.040 0.968 -0.002 -0.004
## .pzoop ~~
## .estfish_bsmt 0.088 0.043 2.041 0.041 0.088 0.201
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.453 0.062 7.314 0.000 0.453 0.823
## .hzoop 0.384 0.052 7.314 0.000 0.384 0.644
## .pzoop 0.309 0.042 7.314 0.000 0.309 0.729
## .estfish_bsmt 0.614 0.084 7.314 0.000 0.614 0.871
##
## R-Square:
## Estimate
## chla 0.177
## hzoop 0.356
## pzoop 0.271
## estfish_bsmt 0.129
summary(modfitN, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 45 iterations
##
## Optimization method NLMINB
## Number of free parameters 40
##
## Used Total
## Number of observations 99 312
##
## Estimator ML
## Model Fit Test Statistic 11.664
## Degrees of freedom 10
## P-value (Chi-square) 0.308
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## chla_1 0.257 0.104 2.469 0.014 0.257 0.244
## hzoop_1 -0.049 0.136 -0.358 0.721 -0.049 -0.038
## corbic_1 -0.088 0.070 -1.255 0.209 -0.088 -0.121
## flow -0.392 0.273 -1.437 0.151 -0.392 -0.147
## temp 0.146 0.267 0.547 0.585 0.146 0.055
## secchi -0.041 0.084 -0.483 0.629 -0.041 -0.049
## hzoop ~
## chla_1 -0.093 0.081 -1.143 0.253 -0.093 -0.110
## hzoop_1 0.083 0.113 0.734 0.463 0.083 0.080
## pzoop_1 -0.005 0.082 -0.061 0.951 -0.005 -0.006
## corbic_1 0.024 0.054 0.440 0.660 0.024 0.040
## estfish_bsmt_1 -0.003 0.084 -0.035 0.972 -0.003 -0.003
## flow -0.416 0.215 -1.936 0.053 -0.416 -0.194
## temp 0.444 0.206 2.158 0.031 0.444 0.208
## secchi -0.161 0.065 -2.499 0.012 -0.161 -0.242
## pzoop ~
## chla_1 0.185 0.083 2.236 0.025 0.185 0.192
## hzoop_1 0.142 0.115 1.235 0.217 0.142 0.120
## pzoop_1 0.329 0.085 3.860 0.000 0.329 0.352
## corbic_1 0.037 0.055 0.677 0.498 0.037 0.055
## estfish_bsmt_1 -0.093 0.088 -1.050 0.294 -0.093 -0.092
## flow -0.727 0.218 -3.333 0.001 -0.727 -0.297
## temp 0.028 0.209 0.135 0.893 0.028 0.012
## secchi -0.035 0.065 -0.535 0.592 -0.035 -0.046
## estfish_bsmt ~
## hzoop_1 0.318 0.107 2.977 0.003 0.318 0.304
## pzoop_1 0.016 0.078 0.200 0.841 0.016 0.019
## estfish_bsmt_1 0.064 0.086 0.745 0.456 0.064 0.072
## flow -0.591 0.205 -2.879 0.004 -0.591 -0.274
## temp -0.275 0.196 -1.403 0.161 -0.275 -0.128
## secchi -0.000 0.062 -0.001 0.999 -0.000 -0.000
## sside_1 -0.057 0.073 -0.782 0.434 -0.057 -0.069
## cent_1 -0.171 0.067 -2.576 0.010 -0.171 -0.233
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla ~~
## .hzoop -0.095 0.039 -2.441 0.015 -0.095 -0.253
## .pzoop 0.016 0.038 0.407 0.684 0.016 0.041
## .estfish_bsmt 0.023 0.036 0.643 0.520 0.023 0.065
## .hzoop ~~
## .pzoop 0.088 0.031 2.897 0.004 0.088 0.304
## .estfish_bsmt -0.025 0.027 -0.905 0.365 -0.025 -0.091
## .pzoop ~~
## .estfish_bsmt -0.010 0.028 -0.347 0.729 -0.010 -0.035
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.491 0.070 7.036 0.000 0.491 0.864
## .hzoop 0.287 0.041 7.036 0.000 0.287 0.781
## .pzoop 0.294 0.042 7.036 0.000 0.294 0.618
## .estfish_bsmt 0.257 0.036 7.036 0.000 0.257 0.692
##
## R-Square:
## Estimate
## chla 0.136
## hzoop 0.219
## pzoop 0.382
## estfish_bsmt 0.308
summary(modfitS, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 52 iterations
##
## Optimization method NLMINB
## Number of free parameters 42
##
## Used Total
## Number of observations 102 312
##
## Estimator ML
## Model Fit Test Statistic 4.341
## Degrees of freedom 8
## P-value (Chi-square) 0.825
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## chla_1 0.196 0.089 2.201 0.028 0.196 0.192
## hzoop_1 0.398 0.170 2.334 0.020 0.398 0.207
## corbic_1 0.027 0.071 0.379 0.705 0.027 0.033
## estfish_bsmt_1 0.417 0.125 3.349 0.001 0.417 0.312
## flow -0.311 0.157 -1.985 0.047 -0.311 -0.176
## temp 0.174 0.312 0.558 0.577 0.174 0.049
## secchi -0.010 0.094 -0.111 0.912 -0.010 -0.010
## hzoop ~
## chla_1 0.083 0.044 1.908 0.056 0.083 0.165
## hzoop_1 0.175 0.082 2.133 0.033 0.175 0.185
## pzoop_1 0.008 0.050 0.160 0.873 0.008 0.014
## corbic_1 0.084 0.034 2.472 0.013 0.084 0.212
## estfish_bsmt_1 -0.158 0.062 -2.558 0.011 -0.158 -0.240
## flow -0.136 0.075 -1.817 0.069 -0.136 -0.156
## temp 0.637 0.149 4.281 0.000 0.637 0.365
## secchi -0.002 0.045 -0.043 0.966 -0.002 -0.004
## pzoop ~
## chla_1 0.347 0.069 5.024 0.000 0.347 0.379
## hzoop_1 0.312 0.130 2.397 0.017 0.312 0.181
## pzoop_1 0.342 0.079 4.336 0.000 0.342 0.339
## corbic_1 -0.073 0.053 -1.363 0.173 -0.073 -0.101
## estfish_bsmt_1 0.106 0.098 1.084 0.279 0.106 0.089
## flow -0.219 0.118 -1.852 0.064 -0.219 -0.138
## temp -0.069 0.236 -0.293 0.769 -0.069 -0.022
## secchi -0.041 0.071 -0.575 0.565 -0.041 -0.044
## estfish_bsmt ~
## chla_1 0.165 0.062 2.665 0.008 0.165 0.237
## hzoop_1 0.175 0.115 1.529 0.126 0.175 0.134
## pzoop_1 -0.099 0.070 -1.422 0.155 -0.099 -0.130
## estfish_bsmt_1 0.307 0.087 3.535 0.000 0.307 0.337
## flow -0.053 0.106 -0.500 0.617 -0.053 -0.044
## temp -0.158 0.207 -0.764 0.445 -0.158 -0.066
## secchi -0.069 0.065 -1.070 0.285 -0.069 -0.098
## sside_1 0.308 0.089 3.462 0.001 0.308 0.303
## cent_1 -0.017 0.076 -0.229 0.819 -0.017 -0.022
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla ~~
## .hzoop 0.029 0.028 1.057 0.290 0.029 0.105
## .pzoop 0.031 0.044 0.697 0.486 0.031 0.069
## .estfish_bsmt -0.014 0.038 -0.368 0.713 -0.014 -0.036
## .hzoop ~~
## .pzoop 0.034 0.021 1.608 0.108 0.034 0.161
## .estfish_bsmt -0.003 0.018 -0.191 0.849 -0.003 -0.019
## .pzoop ~~
## .estfish_bsmt 0.035 0.029 1.192 0.233 0.035 0.119
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.585 0.082 7.141 0.000 0.585 0.741
## .hzoop 0.133 0.019 7.141 0.000 0.133 0.691
## .pzoop 0.333 0.047 7.141 0.000 0.333 0.524
## .estfish_bsmt 0.254 0.036 7.141 0.000 0.254 0.692
##
## R-Square:
## Estimate
## chla 0.259
## hzoop 0.309
## pzoop 0.476
## estfish_bsmt 0.308
#modificationindices(modfitW)
#residuals(modfitS)
labelsfarwest=createLabels(modfitFW, cnameslag)
labelswest=createLabels(modfitW, cnameslag)
labelsnorth=createLabels(modfitN, cnameslag)
labelssouth=createLabels(modfitS, cnameslag)
#FAR WEST
myLavaanPlot(model=modfitFW, labels=labelsfarwest,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
#WEST
myLavaanPlot(model=modfitW, labels=labelswest,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
#NORTH
myLavaanPlot(model=modfitN, labels=labelsnorth,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
#SOUTH
myLavaanPlot(model=modfitS, labels=labelssouth,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
modFW='din~din_1+chla_1+hzoop_1+pzoop_1+potam_1+flow+temp+secchi
chla~din_1+chla_1+hzoop_1+potam_1+flow+temp+secchi
hzoop~chla_1+hzoop_1+pzoop_1+potam_1+flow+temp+secchi
potam~chla_1+hzoop_1+pzoop_1+potam_1+flow+temp+secchi
'
modW='din~din_1+chla_1+hzoop_1+pzoop_1+potam_1+flow+temp+secchi
chla~din_1+chla_1+hzoop_1+potam_1+flow+temp+secchi
hzoop~chla_1+hzoop_1+pzoop_1+potam_1+flow+temp+secchi
potam~chla_1+hzoop_1+pzoop_1+potam_1+flow+temp+secchi
'
modN='din~din_1+chla_1+hzoop_1+pzoop_1+corbic_1+flow+temp+secchi
chla~din_1+chla_1+hzoop_1+corbic_1+flow+temp+secchi
hzoop~chla_1+hzoop_1+pzoop_1+corbic_1+flow+temp+secchi
corbic~chla_1+hzoop_1+pzoop_1+corbic_1+flow+temp+secchi
'
modS='din~din_1+chla_1+hzoop_1+pzoop_1+corbic_1+flow+temp+secchi
chla~din_1+chla_1+hzoop_1+corbic_1+flow+temp+secchi
hzoop~chla_1+hzoop_1+pzoop_1+corbic_1+flow+temp+secchi
corbic~chla_1+hzoop_1+pzoop_1+corbic_1+flow+temp+secchi
'
modfitFW=sem(modFW, data=filter(fdr_ds,region=="Far West"))
modfitW=sem(modW, data=filter(fdr_ds,region=="West"))
modfitN=sem(modN, data=filter(fdr_ds,region=="North"))
modfitS=sem(modS, data=filter(fdr_ds,region=="South"))
summary(modfitFW, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 34 iterations
##
## Optimization method NLMINB
## Number of free parameters 39
##
## Used Total
## Number of observations 237 312
##
## Estimator ML
## Model Fit Test Statistic 2.776
## Degrees of freedom 3
## P-value (Chi-square) 0.427
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## din ~
## din_1 0.425 0.059 7.221 0.000 0.425 0.425
## chla_1 -0.010 0.081 -0.125 0.901 -0.010 -0.007
## hzoop_1 0.012 0.060 0.207 0.836 0.012 0.012
## pzoop_1 -0.023 0.066 -0.346 0.729 -0.023 -0.020
## potam_1 -0.011 0.057 -0.193 0.847 -0.011 -0.011
## flow -0.047 0.079 -0.600 0.548 -0.047 -0.038
## temp -0.451 0.184 -2.455 0.014 -0.451 -0.150
## secchi 0.131 0.073 1.789 0.074 0.131 0.116
## chla ~
## din_1 -0.003 0.046 -0.056 0.955 -0.003 -0.004
## chla_1 0.254 0.064 4.002 0.000 0.254 0.255
## hzoop_1 0.058 0.047 1.237 0.216 0.058 0.079
## potam_1 -0.010 0.045 -0.230 0.818 -0.010 -0.014
## flow 0.002 0.061 0.038 0.969 0.002 0.003
## temp 0.270 0.144 1.876 0.061 0.270 0.124
## secchi 0.026 0.057 0.459 0.646 0.026 0.032
## hzoop ~
## chla_1 0.084 0.079 1.064 0.288 0.084 0.062
## hzoop_1 0.362 0.059 6.152 0.000 0.362 0.364
## pzoop_1 0.035 0.066 0.527 0.598 0.035 0.031
## potam_1 -0.185 0.057 -3.270 0.001 -0.185 -0.192
## flow -0.113 0.078 -1.441 0.150 -0.113 -0.092
## temp -0.144 0.181 -0.799 0.425 -0.144 -0.049
## secchi 0.042 0.072 0.584 0.559 0.042 0.038
## potam ~
## chla_1 0.080 0.066 1.199 0.231 0.080 0.057
## hzoop_1 -0.119 0.050 -2.413 0.016 -0.119 -0.116
## pzoop_1 -0.180 0.056 -3.225 0.001 -0.180 -0.156
## potam_1 0.632 0.048 13.264 0.000 0.632 0.632
## flow 0.047 0.066 0.716 0.474 0.047 0.037
## temp -0.142 0.152 -0.935 0.350 -0.142 -0.047
## secchi -0.061 0.061 -0.996 0.319 -0.061 -0.053
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .din ~~
## .chla -0.091 0.036 -2.502 0.012 -0.091 -0.165
## .hzoop 0.051 0.046 1.110 0.267 0.051 0.072
## .potam -0.043 0.038 -1.112 0.266 -0.043 -0.072
## .chla ~~
## .hzoop 0.040 0.036 1.119 0.263 0.040 0.073
## .potam 0.024 0.030 0.810 0.418 0.024 0.053
## .hzoop ~~
## .potam 0.046 0.038 1.219 0.223 0.046 0.079
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .din 0.705 0.065 10.886 0.000 0.705 0.775
## .chla 0.436 0.040 10.886 0.000 0.436 0.906
## .hzoop 0.694 0.064 10.886 0.000 0.694 0.789
## .potam 0.490 0.045 10.886 0.000 0.490 0.519
##
## R-Square:
## Estimate
## din 0.225
## chla 0.094
## hzoop 0.211
## potam 0.481
summary(modfitW, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 42 iterations
##
## Optimization method NLMINB
## Number of free parameters 39
##
## Used Total
## Number of observations 257 312
##
## Estimator ML
## Model Fit Test Statistic 11.099
## Degrees of freedom 3
## P-value (Chi-square) 0.011
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## din ~
## din_1 0.453 0.053 8.634 0.000 0.453 0.455
## chla_1 -0.086 0.065 -1.324 0.186 -0.086 -0.067
## hzoop_1 0.058 0.055 1.067 0.286 0.058 0.056
## pzoop_1 0.050 0.061 0.829 0.407 0.050 0.041
## potam_1 0.116 0.053 2.209 0.027 0.116 0.121
## flow -0.323 0.056 -5.793 0.000 -0.323 -0.292
## temp 0.107 0.160 0.669 0.504 0.107 0.033
## secchi -0.092 0.054 -1.690 0.091 -0.092 -0.088
## chla ~
## din_1 -0.112 0.051 -2.189 0.029 -0.112 -0.144
## chla_1 0.161 0.064 2.515 0.012 0.161 0.162
## hzoop_1 0.059 0.052 1.139 0.255 0.059 0.073
## potam_1 0.020 0.052 0.377 0.706 0.020 0.026
## flow 0.076 0.055 1.383 0.167 0.076 0.089
## temp -0.188 0.158 -1.190 0.234 -0.188 -0.073
## secchi 0.034 0.054 0.635 0.525 0.034 0.042
## hzoop ~
## chla_1 0.114 0.070 1.619 0.106 0.114 0.094
## hzoop_1 0.293 0.061 4.808 0.000 0.293 0.297
## pzoop_1 0.034 0.067 0.506 0.613 0.034 0.029
## potam_1 -0.233 0.056 -4.182 0.000 -0.233 -0.256
## flow -0.143 0.061 -2.339 0.019 -0.143 -0.137
## temp 0.073 0.179 0.408 0.683 0.073 0.023
## secchi 0.119 0.061 1.972 0.049 0.119 0.121
## potam ~
## chla_1 -0.049 0.053 -0.915 0.360 -0.049 -0.036
## hzoop_1 -0.027 0.046 -0.590 0.555 -0.027 -0.025
## pzoop_1 0.111 0.052 2.150 0.032 0.111 0.086
## potam_1 0.745 0.042 17.650 0.000 0.745 0.739
## flow -0.102 0.046 -2.200 0.028 -0.102 -0.088
## temp -0.011 0.135 -0.085 0.933 -0.011 -0.003
## secchi 0.088 0.046 1.934 0.053 0.088 0.081
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .din ~~
## .chla -0.068 0.027 -2.502 0.012 -0.068 -0.158
## .hzoop -0.022 0.030 -0.724 0.469 -0.022 -0.045
## .potam 0.039 0.023 1.671 0.095 0.039 0.105
## .chla ~~
## .hzoop 0.093 0.031 3.021 0.003 0.093 0.192
## .potam 0.020 0.023 0.863 0.388 0.020 0.054
## .hzoop ~~
## .potam -0.058 0.026 -2.231 0.026 -0.058 -0.141
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .din 0.438 0.039 11.336 0.000 0.438 0.560
## .chla 0.428 0.038 11.336 0.000 0.428 0.905
## .hzoop 0.544 0.048 11.336 0.000 0.544 0.776
## .potam 0.311 0.027 11.336 0.000 0.311 0.362
##
## R-Square:
## Estimate
## din 0.440
## chla 0.095
## hzoop 0.224
## potam 0.638
summary(modfitN, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 38 iterations
##
## Optimization method NLMINB
## Number of free parameters 39
##
## Used Total
## Number of observations 255 312
##
## Estimator ML
## Model Fit Test Statistic 9.702
## Degrees of freedom 3
## P-value (Chi-square) 0.021
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## din ~
## din_1 0.144 0.055 2.627 0.009 0.144 0.146
## chla_1 -0.122 0.053 -2.291 0.022 -0.122 -0.120
## hzoop_1 0.181 0.082 2.209 0.027 0.181 0.128
## pzoop_1 0.234 0.071 3.298 0.001 0.234 0.191
## corbic_1 -0.050 0.046 -1.097 0.273 -0.050 -0.058
## flow -0.383 0.057 -6.735 0.000 -0.383 -0.365
## temp 0.061 0.159 0.381 0.703 0.061 0.020
## secchi -0.026 0.047 -0.546 0.585 -0.026 -0.029
## chla ~
## din_1 0.020 0.062 0.322 0.747 0.020 0.021
## chla_1 0.266 0.060 4.415 0.000 0.266 0.267
## hzoop_1 -0.185 0.086 -2.143 0.032 -0.185 -0.134
## corbic_1 0.021 0.052 0.396 0.692 0.021 0.024
## flow -0.031 0.064 -0.489 0.625 -0.031 -0.031
## temp 0.411 0.181 2.277 0.023 0.411 0.140
## secchi -0.086 0.054 -1.611 0.107 -0.086 -0.099
## hzoop ~
## chla_1 -0.006 0.042 -0.151 0.880 -0.006 -0.009
## hzoop_1 0.137 0.066 2.072 0.038 0.137 0.137
## pzoop_1 0.010 0.057 0.170 0.865 0.010 0.011
## corbic_1 0.005 0.037 0.124 0.901 0.005 0.007
## flow -0.095 0.045 -2.113 0.035 -0.095 -0.127
## temp 0.423 0.129 3.288 0.001 0.423 0.198
## secchi -0.128 0.038 -3.367 0.001 -0.128 -0.202
## corbic ~
## chla_1 0.010 0.064 0.161 0.872 0.010 0.009
## hzoop_1 0.018 0.101 0.183 0.855 0.018 0.011
## pzoop_1 -0.053 0.087 -0.612 0.541 -0.053 -0.038
## corbic_1 0.468 0.056 8.296 0.000 0.468 0.462
## flow 0.025 0.068 0.366 0.715 0.025 0.020
## temp -0.157 0.196 -0.801 0.423 -0.157 -0.045
## secchi 0.126 0.058 2.170 0.030 0.126 0.121
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .din ~~
## .chla -0.083 0.033 -2.490 0.013 -0.083 -0.158
## .hzoop 0.024 0.023 1.015 0.310 0.024 0.064
## .corbic -0.026 0.036 -0.740 0.459 -0.026 -0.046
## .chla ~~
## .hzoop 0.003 0.027 0.131 0.896 0.003 0.008
## .corbic -0.044 0.041 -1.093 0.274 -0.044 -0.069
## .hzoop ~~
## .corbic -0.025 0.029 -0.876 0.381 -0.025 -0.055
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .din 0.462 0.041 11.292 0.000 0.462 0.662
## .chla 0.597 0.053 11.292 0.000 0.597 0.893
## .hzoop 0.302 0.027 11.292 0.000 0.302 0.858
## .corbic 0.702 0.062 11.292 0.000 0.702 0.746
##
## R-Square:
## Estimate
## din 0.338
## chla 0.107
## hzoop 0.142
## corbic 0.254
summary(modfitS, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 45 iterations
##
## Optimization method NLMINB
## Number of free parameters 39
##
## Used Total
## Number of observations 257 312
##
## Estimator ML
## Model Fit Test Statistic 5.831
## Degrees of freedom 3
## P-value (Chi-square) 0.120
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## din ~
## din_1 0.214 0.059 3.603 0.000 0.214 0.214
## chla_1 0.030 0.045 0.669 0.503 0.030 0.040
## hzoop_1 0.068 0.084 0.810 0.418 0.068 0.050
## pzoop_1 -0.004 0.055 -0.064 0.949 -0.004 -0.004
## corbic_1 0.046 0.038 1.192 0.233 0.046 0.070
## flow -0.054 0.046 -1.178 0.239 -0.054 -0.069
## temp 0.234 0.154 1.516 0.129 0.234 0.088
## secchi -0.185 0.046 -4.060 0.000 -0.185 -0.251
## chla ~
## din_1 -0.021 0.082 -0.252 0.801 -0.021 -0.016
## chla_1 0.274 0.060 4.559 0.000 0.274 0.274
## hzoop_1 0.216 0.111 1.943 0.052 0.216 0.120
## corbic_1 0.065 0.052 1.243 0.214 0.065 0.075
## flow -0.118 0.062 -1.886 0.059 -0.118 -0.113
## temp 0.049 0.206 0.238 0.812 0.049 0.014
## secchi -0.027 0.062 -0.436 0.663 -0.027 -0.028
## hzoop ~
## chla_1 0.081 0.032 2.553 0.011 0.081 0.145
## hzoop_1 0.309 0.058 5.357 0.000 0.309 0.310
## pzoop_1 -0.021 0.038 -0.545 0.586 -0.021 -0.031
## corbic_1 0.082 0.027 3.042 0.002 0.082 0.170
## flow -0.049 0.032 -1.523 0.128 -0.049 -0.085
## temp 0.439 0.108 4.068 0.000 0.439 0.226
## secchi 0.066 0.030 2.170 0.030 0.066 0.122
## corbic ~
## chla_1 0.050 0.067 0.741 0.459 0.050 0.044
## hzoop_1 -0.001 0.123 -0.008 0.993 -0.001 -0.000
## pzoop_1 -0.058 0.082 -0.711 0.477 -0.058 -0.042
## corbic_1 0.320 0.057 5.577 0.000 0.320 0.323
## flow 0.078 0.069 1.139 0.255 0.078 0.066
## temp -0.290 0.230 -1.260 0.208 -0.290 -0.073
## secchi -0.207 0.065 -3.181 0.001 -0.207 -0.185
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .din ~~
## .chla -0.003 0.029 -0.096 0.923 -0.003 -0.006
## .hzoop 0.051 0.015 3.311 0.001 0.051 0.211
## .corbic -0.043 0.032 -1.318 0.187 -0.043 -0.083
## .chla ~~
## .hzoop 0.037 0.021 1.789 0.074 0.037 0.112
## .corbic -0.031 0.044 -0.714 0.475 -0.031 -0.045
## .hzoop ~~
## .corbic 0.030 0.023 1.316 0.188 0.030 0.082
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .din 0.346 0.031 11.336 0.000 0.346 0.827
## .chla 0.633 0.056 11.336 0.000 0.633 0.866
## .hzoop 0.170 0.015 11.336 0.000 0.170 0.754
## .corbic 0.774 0.068 11.336 0.000 0.774 0.810
##
## R-Square:
## Estimate
## din 0.173
## chla 0.134
## hzoop 0.246
## corbic 0.190
#modificationindices(modfitW)
#residuals(modfitS)
labelsfarwest=createLabels(modfitFW, cnameslag)
labelswest=createLabels(modfitW, cnameslag)
labelsnorth=createLabels(modfitN, cnameslag)
labelssouth=createLabels(modfitS, cnameslag)
#FAR WEST
myLavaanPlot(model=modfitFW, labels=labelsfarwest,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
#WEST
myLavaanPlot(model=modfitW, labels=labelswest,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
#NORTH
myLavaanPlot(model=modfitN, labels=labelsnorth,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
#SOUTH
myLavaanPlot(model=modfitS, labels=labelssouth,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
These models do use time lags.
Note: You get somewhat different answers if you use a multigroup model vs. fit each region individually. I am not entirely sure why, but I think there is some data pooling going on like in hierarchical models. I would have to look into the math. I know that if you use the multigroup framework you can impose constraints like requiring certain parameters to be the same across groups (see lavaan manual). Obviously, if data on a variable you want to use are missing from one site, you can’t use the multigroup option (you will get an error) and have to fit individually.
Clams don’t seem to have any impact on chla. Dropping dophos because strongly correlated with ammonia.
# mod1='chla~ammonia+dophos+chla_1+flow_1
# ammonia~flow_1+chla_1
# dophos~flow_1
# ammonia~~dophos'
modfww='chla~ammonia+chla_1+flow_1+secchi_1+temp_1+potam_1
ammonia~flow_1+chla_1+secchi_1+temp_1+potam_1'
modns='chla~ammonia+chla_1+flow_1+secchi_1+temp_1+corbic_1
ammonia~flow_1+chla_1+secchi_1+temp_1+corbic_1'
#you can either do a multigroup model by region
# modfit1=sem(mod1, data=fdr_ds, group = "region")
# summary(modfit1, standardized=T, rsq=T)
#
# par(mfrow=c(2,2))
# semPaths(modfit1, "std", edge.label.cex = 1, residuals = F, node.width=3, nCharNodes = 0, intercepts = F, title = T)
# #residuals(modfit1)
#or fit separately for each region
modfitFW=sem(modfww, data=filter(fdr_ds,region=="Far West"))
modfitW=sem(modfww, data=filter(fdr_ds,region=="West"))
modfitN=sem(modns, data=filter(fdr_ds,region=="North"))
modfitS=sem(modns, data=filter(fdr_ds,region=="South"))
summary(modfitFW, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 22 iterations
##
## Optimization method NLMINB
## Number of free parameters 13
##
## Used Total
## Number of observations 266 312
##
## Estimator ML
## Model Fit Test Statistic 0.000
## Degrees of freedom 0
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## ammonia -0.307 0.046 -6.732 0.000 -0.307 -0.375
## chla_1 0.277 0.055 5.055 0.000 0.277 0.280
## flow_1 -0.052 0.054 -0.965 0.335 -0.052 -0.059
## secchi_1 0.009 0.050 0.185 0.854 0.009 0.012
## temp_1 -0.163 0.123 -1.328 0.184 -0.163 -0.076
## potam_1 0.007 0.041 0.173 0.862 0.007 0.010
## ammonia ~
## flow_1 -0.211 0.072 -2.942 0.003 -0.211 -0.193
## chla_1 0.047 0.074 0.640 0.522 0.047 0.039
## secchi_1 -0.114 0.067 -1.698 0.089 -0.114 -0.116
## temp_1 0.040 0.165 0.243 0.808 0.040 0.015
## potam_1 0.092 0.055 1.657 0.097 0.092 0.100
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.389 0.034 11.533 0.000 0.389 0.788
## .ammonia 0.703 0.061 11.533 0.000 0.703 0.956
##
## R-Square:
## Estimate
## chla 0.212
## ammonia 0.044
summary(modfitW, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 21 iterations
##
## Optimization method NLMINB
## Number of free parameters 13
##
## Used Total
## Number of observations 267 312
##
## Estimator ML
## Model Fit Test Statistic 0.000
## Degrees of freedom 0
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## ammonia -0.257 0.064 -4.012 0.000 -0.257 -0.253
## chla_1 0.228 0.059 3.827 0.000 0.228 0.216
## flow_1 0.037 0.055 0.660 0.510 0.037 0.043
## secchi_1 0.093 0.053 1.748 0.080 0.093 0.108
## temp_1 -0.470 0.156 -3.013 0.003 -0.470 -0.173
## potam_1 -0.045 0.049 -0.931 0.352 -0.045 -0.057
## ammonia ~
## flow_1 -0.380 0.048 -7.990 0.000 -0.380 -0.456
## chla_1 0.063 0.057 1.118 0.263 0.063 0.061
## secchi_1 -0.023 0.051 -0.456 0.648 -0.023 -0.027
## temp_1 0.191 0.148 1.288 0.198 0.191 0.071
## potam_1 0.041 0.046 0.893 0.372 0.041 0.053
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.436 0.038 11.554 0.000 0.436 0.824
## .ammonia 0.398 0.034 11.554 0.000 0.398 0.774
##
## R-Square:
## Estimate
## chla 0.176
## ammonia 0.226
summary(modfitN, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 24 iterations
##
## Optimization method NLMINB
## Number of free parameters 13
##
## Used Total
## Number of observations 267 312
##
## Estimator ML
## Model Fit Test Statistic 0.000
## Degrees of freedom 0
## Minimum Function Value 0.0000000000000
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## ammonia -0.220 0.072 -3.061 0.002 -0.220 -0.189
## chla_1 0.248 0.059 4.178 0.000 0.248 0.246
## flow_1 -0.112 0.060 -1.865 0.062 -0.112 -0.116
## secchi_1 0.027 0.053 0.508 0.612 0.027 0.030
## temp_1 0.127 0.178 0.711 0.477 0.127 0.042
## corbic_1 0.022 0.051 0.431 0.667 0.022 0.026
## ammonia ~
## flow_1 -0.261 0.049 -5.370 0.000 -0.261 -0.315
## chla_1 -0.004 0.051 -0.078 0.938 -0.004 -0.005
## secchi_1 0.003 0.045 0.058 0.954 0.003 0.003
## temp_1 0.108 0.151 0.716 0.474 0.108 0.042
## corbic_1 0.084 0.043 1.937 0.053 0.084 0.114
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.608 0.053 11.554 0.000 0.608 0.898
## .ammonia 0.440 0.038 11.554 0.000 0.440 0.883
##
## R-Square:
## Estimate
## chla 0.102
## ammonia 0.117
summary(modfitS, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 20 iterations
##
## Optimization method NLMINB
## Number of free parameters 13
##
## Used Total
## Number of observations 267 312
##
## Estimator ML
## Model Fit Test Statistic 0.000
## Degrees of freedom 0
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## ammonia -0.348 0.066 -5.291 0.000 -0.348 -0.291
## chla_1 0.319 0.055 5.748 0.000 0.319 0.316
## flow_1 -0.181 0.054 -3.353 0.001 -0.181 -0.185
## secchi_1 -0.036 0.055 -0.644 0.519 -0.036 -0.036
## temp_1 0.285 0.190 1.501 0.133 0.285 0.082
## corbic_1 0.097 0.049 1.986 0.047 0.097 0.112
## ammonia ~
## flow_1 -0.040 0.050 -0.801 0.423 -0.040 -0.049
## chla_1 0.110 0.051 2.143 0.032 0.110 0.130
## secchi_1 -0.091 0.051 -1.781 0.075 -0.091 -0.112
## temp_1 -0.198 0.176 -1.127 0.260 -0.198 -0.068
## corbic_1 -0.008 0.046 -0.179 0.858 -0.008 -0.011
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.563 0.049 11.554 0.000 0.563 0.778
## .ammonia 0.487 0.042 11.554 0.000 0.487 0.963
##
## R-Square:
## Estimate
## chla 0.222
## ammonia 0.037
labelsfarwest=createLabels(modfitFW, cnameslag)
labelswest=createLabels(modfitW, cnameslag)
labelsnorth=createLabels(modfitN, cnameslag)
labelssouth=createLabels(modfitS, cnameslag)
#FAR WEST
myLavaanPlot(model=modfitFW, labels=labelsfarwest,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=F, sig=0.05,
width=c("regress","latent","covs"),
color=c("regress","latent","covs"))
#WEST
myLavaanPlot(model=modfitW, labels=labelswest,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=F, sig=0.05,
width=c("regress","latent","covs"),
color=c("regress","latent","covs"))
#NORTH
myLavaanPlot(model=modfitN, labels=labelsnorth,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=F, sig=0.05,
width=c("regress","latent","covs"),
color=c("regress","latent","covs"))
#SOUTH
myLavaanPlot(model=modfitS, labels=labelssouth,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=F, sig=0.05,
width=c("regress","latent","covs"),
color=c("regress","latent","covs"))
#residuals(modfitFW)
modFW='chla~chla_1+hcope_1+amphi_1+flow_1+secchi_1+temp_1+potam_1
amphi~chla_1+amphi_1+flow_1+secchi_1+temp_1+potam_1
hcope~chla_1+hcope_1+flow_1+pcope_1+secchi_1+temp_1+potam_1
pcope~chla_1+pcope_1+hcope_1+amphi_1+flow_1+secchi_1+temp_1+potam_1
'
modW='chla~chla_1+hcope_1+flow_1+secchi_1+temp_1+potam_1
amphi~chla_1+amphi_1+flow_1+secchi_1+temp_1+potam_1
hcope~chla_1+hcope_1+mysid_1+pcope_1+flow_1+secchi_1+temp_1+potam_1
pcope~chla_1+pcope_1+hcope_1+mysid_1+flow_1+secchi_1+temp_1+potam_1
mysid~chla_1+mysid_1+hcope_1+pcope_1+flow_1+secchi_1+temp_1+potam_1
'
modN='chla~chla_1+hcope_1+amphi_1+flow_1+secchi_1+temp_1+corbic_1
amphi~chla_1+amphi_1+flow_1+secchi_1+temp_1+corbic_1
hcope~chla_1+hcope_1+flow_1+pcope_1+secchi_1+temp_1+corbic_1
pcope~chla_1+pcope_1+hcope_1+flow_1+secchi_1+temp_1+corbic_1
mysid~chla_1+mysid_1+hcope_1+pcope_1+flow_1+secchi_1+temp_1+corbic_1
'
modS='chla~chla_1+hcope_1+clad_1+flow_1+secchi_1+temp_1+corbic_1
clad~chla_1+clad_1+flow_1+pcope_1+secchi_1+temp_1+corbic_1
hcope~chla_1+hcope_1+flow_1+pcope_1+secchi_1+temp_1+corbic_1
amphi~chla_1+amphi_1+flow_1+secchi_1+temp_1+corbic_1
pcope~chla_1+pcope_1+hcope_1+clad_1+flow_1+secchi_1+temp_1+corbic_1
'
modfitFW=sem(modFW, data=filter(fdr_ds,region=="Far West"))
modfitW=sem(modW, data=filter(fdr_ds,region=="West"))
modfitN=sem(modN, data=filter(fdr_ds,region=="North"))
modfitS=sem(modS, data=filter(fdr_ds,region=="South"))
summary(modfitFW, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 39 iterations
##
## Optimization method NLMINB
## Number of free parameters 38
##
## Used Total
## Number of observations 238 312
##
## Estimator ML
## Model Fit Test Statistic 6.201
## Degrees of freedom 4
## P-value (Chi-square) 0.185
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## chla_1 0.236 0.062 3.785 0.000 0.236 0.237
## hcope_1 0.078 0.045 1.720 0.085 0.078 0.108
## amphi_1 0.099 0.055 1.803 0.071 0.099 0.132
## flow_1 0.096 0.068 1.405 0.160 0.096 0.106
## secchi_1 0.028 0.057 0.498 0.619 0.028 0.035
## temp_1 -0.083 0.141 -0.588 0.556 -0.083 -0.038
## potam_1 -0.016 0.045 -0.352 0.725 -0.016 -0.022
## amphi ~
## chla_1 0.041 0.042 0.976 0.329 0.041 0.031
## amphi_1 0.754 0.037 20.525 0.000 0.754 0.765
## flow_1 -0.227 0.046 -4.936 0.000 -0.227 -0.191
## secchi_1 -0.023 0.038 -0.617 0.537 -0.023 -0.022
## temp_1 0.012 0.094 0.125 0.901 0.012 0.004
## potam_1 0.015 0.030 0.496 0.620 0.015 0.016
## hcope ~
## chla_1 0.112 0.083 1.354 0.176 0.112 0.081
## hcope_1 0.288 0.061 4.710 0.000 0.288 0.288
## flow_1 -0.185 0.085 -2.183 0.029 -0.185 -0.148
## pcope_1 0.146 0.085 1.720 0.086 0.146 0.109
## secchi_1 -0.025 0.075 -0.335 0.738 -0.025 -0.023
## temp_1 -0.200 0.189 -1.059 0.290 -0.200 -0.067
## potam_1 -0.175 0.060 -2.920 0.003 -0.175 -0.178
## pcope ~
## chla_1 -0.061 0.059 -1.039 0.299 -0.061 -0.060
## pcope_1 0.342 0.060 5.671 0.000 0.342 0.348
## hcope_1 0.028 0.043 0.653 0.514 0.028 0.038
## amphi_1 -0.140 0.051 -2.771 0.006 -0.140 -0.184
## flow_1 0.063 0.066 0.966 0.334 0.063 0.069
## secchi_1 0.181 0.053 3.398 0.001 0.181 0.220
## temp_1 -0.079 0.133 -0.592 0.554 -0.079 -0.036
## potam_1 -0.057 0.043 -1.341 0.180 -0.057 -0.079
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla ~~
## .amphi 0.005 0.019 0.248 0.804 0.005 0.016
## .hcope 0.026 0.037 0.700 0.484 0.026 0.045
## .pcope 0.006 0.026 0.244 0.807 0.006 0.016
## .amphi ~~
## .hcope 0.004 0.025 0.176 0.860 0.004 0.011
## .pcope -0.010 0.018 -0.588 0.557 -0.010 -0.038
## .hcope ~~
## .pcope -0.121 0.036 -3.342 0.001 -0.121 -0.222
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.433 0.040 10.909 0.000 0.433 0.904
## .amphi 0.195 0.018 10.909 0.000 0.195 0.236
## .hcope 0.769 0.071 10.909 0.000 0.769 0.840
## .pcope 0.384 0.035 10.909 0.000 0.384 0.773
##
## R-Square:
## Estimate
## chla 0.096
## amphi 0.764
## hcope 0.160
## pcope 0.227
summary(modfitW, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 50 iterations
##
## Optimization method NLMINB
## Number of free parameters 51
##
## Used Total
## Number of observations 258 312
##
## Estimator ML
## Model Fit Test Statistic 16.569
## Degrees of freedom 9
## P-value (Chi-square) 0.056
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## chla_1 0.170 0.060 2.821 0.005 0.170 0.171
## hcope_1 0.082 0.054 1.531 0.126 0.082 0.101
## flow_1 0.148 0.051 2.870 0.004 0.148 0.187
## secchi_1 0.094 0.052 1.795 0.073 0.094 0.116
## temp_1 -0.537 0.152 -3.528 0.000 -0.537 -0.210
## potam_1 -0.004 0.050 -0.087 0.931 -0.004 -0.006
## amphi ~
## chla_1 -0.018 0.047 -0.383 0.702 -0.018 -0.013
## amphi_1 0.808 0.037 21.950 0.000 0.808 0.814
## flow_1 0.037 0.038 0.968 0.333 0.037 0.033
## secchi_1 0.099 0.043 2.292 0.022 0.099 0.086
## temp_1 -0.187 0.120 -1.556 0.120 -0.187 -0.051
## potam_1 0.025 0.039 0.639 0.523 0.025 0.024
## hcope ~
## chla_1 0.083 0.071 1.161 0.246 0.083 0.069
## hcope_1 0.252 0.066 3.837 0.000 0.252 0.255
## mysid_1 0.144 0.067 2.131 0.033 0.144 0.142
## pcope_1 -0.044 0.070 -0.630 0.529 -0.044 -0.039
## flow_1 0.000 0.064 0.006 0.995 0.000 0.000
## secchi_1 0.064 0.067 0.959 0.337 0.064 0.066
## temp_1 -0.168 0.184 -0.911 0.362 -0.168 -0.054
## potam_1 -0.146 0.060 -2.437 0.015 -0.146 -0.162
## pcope ~
## chla_1 -0.071 0.056 -1.273 0.203 -0.071 -0.067
## pcope_1 0.404 0.056 7.214 0.000 0.404 0.407
## hcope_1 -0.106 0.052 -2.048 0.041 -0.106 -0.122
## mysid_1 0.160 0.054 2.970 0.003 0.160 0.180
## flow_1 0.242 0.051 4.754 0.000 0.242 0.288
## secchi_1 0.132 0.053 2.502 0.012 0.132 0.154
## temp_1 0.178 0.145 1.224 0.221 0.178 0.066
## potam_1 0.064 0.047 1.348 0.178 0.064 0.080
## mysid ~
## chla_1 0.110 0.061 1.795 0.073 0.110 0.096
## mysid_1 0.364 0.058 6.226 0.000 0.364 0.380
## hcope_1 0.055 0.056 0.973 0.331 0.055 0.059
## pcope_1 0.099 0.061 1.626 0.104 0.099 0.092
## flow_1 -0.070 0.055 -1.267 0.205 -0.070 -0.078
## secchi_1 -0.093 0.058 -1.615 0.106 -0.093 -0.100
## temp_1 0.272 0.158 1.718 0.086 0.272 0.093
## potam_1 -0.161 0.052 -3.113 0.002 -0.161 -0.187
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla ~~
## .amphi 0.010 0.020 0.491 0.623 0.010 0.031
## .hcope 0.086 0.030 2.815 0.005 0.086 0.178
## .pcope 0.018 0.024 0.767 0.443 0.018 0.048
## .mysid 0.056 0.026 2.137 0.033 0.056 0.134
## .amphi ~~
## .hcope -0.026 0.024 -1.102 0.271 -0.026 -0.069
## .pcope 0.034 0.019 1.830 0.067 0.034 0.115
## .mysid -0.017 0.020 -0.818 0.414 -0.017 -0.051
## .hcope ~~
## .pcope 0.072 0.028 2.574 0.010 0.072 0.162
## .mysid 0.116 0.031 3.739 0.000 0.116 0.239
## .pcope ~~
## .mysid 0.028 0.024 1.186 0.236 0.028 0.074
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.411 0.036 11.358 0.000 0.411 0.868
## .amphi 0.256 0.023 11.358 0.000 0.256 0.265
## .hcope 0.565 0.050 11.358 0.000 0.565 0.819
## .pcope 0.351 0.031 11.358 0.000 0.351 0.659
## .mysid 0.417 0.037 11.358 0.000 0.417 0.673
##
## R-Square:
## Estimate
## chla 0.132
## amphi 0.735
## hcope 0.181
## pcope 0.341
## mysid 0.327
summary(modfitN, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 49 iterations
##
## Optimization method NLMINB
## Number of free parameters 50
##
## Used Total
## Number of observations 256 312
##
## Estimator ML
## Model Fit Test Statistic 16.783
## Degrees of freedom 10
## P-value (Chi-square) 0.079
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## chla_1 0.256 0.060 4.235 0.000 0.256 0.257
## hcope_1 -0.170 0.102 -1.660 0.097 -0.170 -0.120
## amphi_1 0.077 0.054 1.434 0.152 0.077 0.085
## flow_1 -0.125 0.066 -1.890 0.059 -0.125 -0.133
## secchi_1 0.029 0.054 0.539 0.590 0.029 0.033
## temp_1 0.166 0.183 0.907 0.365 0.166 0.057
## corbic_1 -0.008 0.051 -0.160 0.873 -0.008 -0.010
## amphi ~
## chla_1 0.125 0.060 2.095 0.036 0.125 0.113
## amphi_1 0.487 0.053 9.127 0.000 0.487 0.485
## flow_1 -0.026 0.057 -0.459 0.646 -0.026 -0.025
## secchi_1 0.012 0.053 0.226 0.821 0.012 0.012
## temp_1 -0.501 0.178 -2.819 0.005 -0.501 -0.153
## corbic_1 -0.042 0.051 -0.819 0.413 -0.042 -0.044
## hcope ~
## chla_1 -0.010 0.037 -0.264 0.791 -0.010 -0.015
## hcope_1 0.195 0.064 3.034 0.002 0.195 0.205
## flow_1 -0.202 0.041 -4.923 0.000 -0.202 -0.319
## pcope_1 -0.056 0.042 -1.343 0.179 -0.056 -0.079
## secchi_1 -0.040 0.035 -1.128 0.259 -0.040 -0.068
## temp_1 0.183 0.113 1.620 0.105 0.183 0.093
## corbic_1 0.024 0.032 0.753 0.451 0.024 0.042
## pcope ~
## chla_1 0.046 0.055 0.841 0.400 0.046 0.050
## pcope_1 0.361 0.062 5.860 0.000 0.361 0.363
## hcope_1 -0.145 0.094 -1.532 0.125 -0.145 -0.108
## flow_1 -0.029 0.060 -0.474 0.635 -0.029 -0.032
## secchi_1 0.006 0.052 0.106 0.915 0.006 0.007
## temp_1 0.277 0.167 1.663 0.096 0.277 0.101
## corbic_1 0.040 0.047 0.862 0.389 0.040 0.051
## mysid ~
## chla_1 0.035 0.055 0.641 0.522 0.035 0.036
## mysid_1 0.112 0.063 1.765 0.078 0.112 0.112
## hcope_1 0.111 0.103 1.085 0.278 0.111 0.080
## pcope_1 -0.018 0.062 -0.294 0.769 -0.018 -0.018
## flow_1 -0.233 0.061 -3.825 0.000 -0.233 -0.251
## secchi_1 -0.179 0.053 -3.373 0.001 -0.179 -0.207
## temp_1 0.435 0.165 2.627 0.009 0.435 0.150
## corbic_1 -0.019 0.047 -0.404 0.686 -0.019 -0.023
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla ~~
## .amphi 0.022 0.037 0.593 0.553 0.022 0.037
## .hcope 0.034 0.023 1.437 0.151 0.034 0.090
## .pcope -0.052 0.034 -1.515 0.130 -0.052 -0.095
## .mysid 0.068 0.034 1.988 0.047 0.068 0.125
## .amphi ~~
## .hcope 0.021 0.023 0.894 0.372 0.021 0.056
## .pcope -0.052 0.034 -1.539 0.124 -0.052 -0.097
## .mysid 0.037 0.034 1.097 0.273 0.037 0.069
## .hcope ~~
## .pcope 0.080 0.022 3.674 0.000 0.080 0.236
## .mysid 0.189 0.024 7.827 0.000 0.189 0.561
## .pcope ~~
## .mysid 0.133 0.032 4.134 0.000 0.133 0.267
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.603 0.053 11.314 0.000 0.603 0.903
## .amphi 0.591 0.052 11.314 0.000 0.591 0.713
## .hcope 0.230 0.020 11.314 0.000 0.230 0.769
## .pcope 0.500 0.044 11.314 0.000 0.500 0.851
## .mysid 0.492 0.043 11.314 0.000 0.492 0.760
##
## R-Square:
## Estimate
## chla 0.097
## amphi 0.287
## hcope 0.231
## pcope 0.149
## mysid 0.240
summary(modfitS, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 50 iterations
##
## Optimization method NLMINB
## Number of free parameters 50
##
## Used Total
## Number of observations 258 312
##
## Estimator ML
## Model Fit Test Statistic 6.002
## Degrees of freedom 10
## P-value (Chi-square) 0.815
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## chla_1 0.236 0.061 3.862 0.000 0.236 0.236
## hcope_1 0.061 0.106 0.579 0.563 0.061 0.037
## clad_1 0.155 0.068 2.262 0.024 0.155 0.142
## flow_1 -0.195 0.064 -3.056 0.002 -0.195 -0.202
## secchi_1 -0.031 0.059 -0.527 0.598 -0.031 -0.032
## temp_1 0.242 0.201 1.203 0.229 0.242 0.070
## corbic_1 0.085 0.052 1.629 0.103 0.085 0.098
## clad ~
## chla_1 0.105 0.050 2.110 0.035 0.105 0.115
## clad_1 0.470 0.056 8.398 0.000 0.470 0.476
## flow_1 0.072 0.048 1.499 0.134 0.072 0.081
## pcope_1 -0.003 0.048 -0.056 0.955 -0.003 -0.003
## secchi_1 0.152 0.048 3.152 0.002 0.152 0.172
## temp_1 0.048 0.163 0.297 0.767 0.048 0.015
## corbic_1 0.049 0.042 1.157 0.247 0.049 0.062
## hcope ~
## chla_1 0.059 0.032 1.852 0.064 0.059 0.102
## hcope_1 0.333 0.059 5.627 0.000 0.333 0.342
## flow_1 -0.091 0.034 -2.709 0.007 -0.091 -0.163
## pcope_1 0.029 0.033 0.875 0.382 0.029 0.048
## secchi_1 0.045 0.033 1.367 0.171 0.045 0.079
## temp_1 -0.162 0.110 -1.468 0.142 -0.162 -0.081
## corbic_1 0.071 0.029 2.489 0.013 0.071 0.142
## amphi ~
## chla_1 0.042 0.058 0.715 0.475 0.042 0.043
## amphi_1 0.188 0.060 3.115 0.002 0.188 0.188
## flow_1 0.030 0.057 0.517 0.605 0.030 0.032
## secchi_1 -0.156 0.059 -2.630 0.009 -0.156 -0.167
## temp_1 -0.159 0.200 -0.794 0.427 -0.159 -0.048
## corbic_1 0.011 0.052 0.217 0.828 0.011 0.013
## pcope ~
## chla_1 0.189 0.055 3.434 0.001 0.189 0.194
## pcope_1 0.458 0.055 8.342 0.000 0.458 0.463
## hcope_1 -0.140 0.097 -1.437 0.151 -0.140 -0.086
## clad_1 0.043 0.063 0.694 0.488 0.043 0.041
## flow_1 0.068 0.057 1.183 0.237 0.068 0.072
## secchi_1 0.067 0.053 1.263 0.207 0.067 0.071
## temp_1 0.148 0.181 0.821 0.412 0.148 0.044
## corbic_1 -0.024 0.047 -0.518 0.604 -0.024 -0.029
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla ~~
## .clad 0.117 0.032 3.672 0.000 0.117 0.235
## .hcope 0.019 0.021 0.894 0.372 0.019 0.056
## .amphi 0.007 0.038 0.192 0.847 0.007 0.012
## .pcope -0.028 0.034 -0.834 0.404 -0.028 -0.052
## .clad ~~
## .hcope 0.033 0.017 1.939 0.053 0.033 0.122
## .amphi -0.053 0.031 -1.700 0.089 -0.053 -0.106
## .pcope 0.059 0.028 2.108 0.035 0.059 0.132
## .hcope ~~
## .amphi 0.002 0.021 0.099 0.921 0.002 0.006
## .pcope 0.031 0.019 1.664 0.096 0.031 0.104
## .amphi ~~
## .pcope -0.007 0.034 -0.205 0.837 -0.007 -0.013
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.610 0.054 11.358 0.000 0.610 0.837
## .clad 0.404 0.036 11.358 0.000 0.404 0.670
## .hcope 0.184 0.016 11.358 0.000 0.184 0.750
## .amphi 0.621 0.055 11.358 0.000 0.621 0.914
## .pcope 0.489 0.043 11.358 0.000 0.489 0.712
##
## R-Square:
## Estimate
## chla 0.163
## clad 0.330
## hcope 0.250
## amphi 0.086
## pcope 0.288
#modificationindices(modfitW)
labelsfarwest=createLabels(modfitFW, cnameslag)
labelswest=createLabels(modfitW, cnameslag)
labelsnorth=createLabels(modfitN, cnameslag)
labelssouth=createLabels(modfitS, cnameslag)
#FAR WEST
myLavaanPlot(model=modfitFW, labels=labelsfarwest,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
#WEST
myLavaanPlot(model=modfitW, labels=labelswest,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
#NORTH
myLavaanPlot(model=modfitN, labels=labelsnorth,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
#SOUTH
myLavaanPlot(model=modfitS, labels=labelssouth,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
Note that because fish have more missing data, more rows get dropped (compared ‘used’ and ‘total’ number of observations to previous summaries).
If you get a warning about variances being negative, that is definitely a problem. It seems to happen when you try to create a latent variables, but the variables that go into it don’t acutally have a common trend.
modFW='estfish_bsmt~hcope_1+amphi_1+pcope_1+flow_1+secchi_1+temp_1+marfish_bsmt_1
'
modW='estfish_bsmt~hcope_1+mysid_1+pcope_1+amphi_1+flow_1+secchi_1+temp_1+marfish_bsmt_1
'
modN='estfish_bsmt~hcope_1+mysid_1+pcope_1+amphi_1+flow_1+secchi_1+temp_1+sside_1
'
modS='estfish_bsmt~hcope_1+clad_1+amphi_1+pcope_1+flow_1+secchi_1+temp_1+sside_1
'
modfitFW=sem(modFW, data=filter(fdr_ds,region=="Far West"))
modfitW=sem(modW, data=filter(fdr_ds,region=="West"))
modfitN=sem(modN, data=filter(fdr_ds,region=="North"))
modfitS=sem(modS, data=filter(fdr_ds,region=="South"))
summary(modfitFW, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 19 iterations
##
## Optimization method NLMINB
## Number of free parameters 8
##
## Used Total
## Number of observations 103 312
##
## Estimator ML
## Model Fit Test Statistic 0.000
## Degrees of freedom 0
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## estfish_bsmt ~
## hcope_1 -0.147 0.070 -2.101 0.036 -0.147 -0.189
## amphi_1 -0.077 0.103 -0.746 0.456 -0.077 -0.089
## pcope_1 0.163 0.113 1.432 0.152 0.163 0.136
## flow_1 0.376 0.176 2.141 0.032 0.376 0.244
## secchi_1 -0.054 0.119 -0.451 0.652 -0.054 -0.046
## temp_1 -0.546 0.272 -2.008 0.045 -0.546 -0.183
## marfish_bsmt_1 0.238 0.153 1.557 0.119 0.238 0.158
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .estfish_bsmt 0.629 0.088 7.176 0.000 0.629 0.773
##
## R-Square:
## Estimate
## estfish_bsmt 0.227
summary(modfitW, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 22 iterations
##
## Optimization method NLMINB
## Number of free parameters 9
##
## Used Total
## Number of observations 108 312
##
## Estimator ML
## Model Fit Test Statistic 0.000
## Degrees of freedom 0
## Minimum Function Value 0.0000000000000
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## estfish_bsmt ~
## hcope_1 0.165 0.113 1.464 0.143 0.165 0.150
## mysid_1 -0.136 0.126 -1.082 0.279 -0.136 -0.123
## pcope_1 -0.037 0.119 -0.309 0.757 -0.037 -0.035
## amphi_1 -0.222 0.077 -2.880 0.004 -0.222 -0.287
## flow_1 -0.070 0.145 -0.481 0.630 -0.070 -0.048
## secchi_1 -0.058 0.125 -0.468 0.639 -0.058 -0.053
## temp_1 -0.203 0.310 -0.653 0.514 -0.203 -0.065
## marfish_bsmt_1 0.146 0.108 1.351 0.177 0.146 0.143
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .estfish_bsmt 0.600 0.082 7.348 0.000 0.600 0.855
##
## R-Square:
## Estimate
## estfish_bsmt 0.145
summary(modfitN, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 19 iterations
##
## Optimization method NLMINB
## Number of free parameters 9
##
## Used Total
## Number of observations 126 312
##
## Estimator ML
## Model Fit Test Statistic 0.000
## Degrees of freedom 0
## Minimum Function Value 0.0000000000000
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## estfish_bsmt ~
## hcope_1 0.096 0.134 0.715 0.475 0.096 0.081
## mysid_1 0.013 0.087 0.146 0.884 0.013 0.016
## pcope_1 0.029 0.060 0.488 0.626 0.029 0.040
## amphi_1 0.008 0.057 0.141 0.888 0.008 0.011
## flow_1 -0.373 0.101 -3.696 0.000 -0.373 -0.353
## secchi_1 -0.030 0.070 -0.429 0.668 -0.030 -0.041
## temp_1 0.290 0.187 1.551 0.121 0.290 0.137
## sside_1 -0.059 0.072 -0.823 0.411 -0.059 -0.067
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .estfish_bsmt 0.306 0.039 7.937 0.000 0.306 0.752
##
## R-Square:
## Estimate
## estfish_bsmt 0.248
summary(modfitS, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 19 iterations
##
## Optimization method NLMINB
## Number of free parameters 9
##
## Used Total
## Number of observations 128 312
##
## Estimator ML
## Model Fit Test Statistic 0.000
## Degrees of freedom 0
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## estfish_bsmt ~
## hcope_1 -0.045 0.125 -0.361 0.718 -0.045 -0.034
## clad_1 0.130 0.070 1.854 0.064 0.130 0.161
## amphi_1 0.102 0.062 1.633 0.102 0.102 0.137
## pcope_1 -0.106 0.057 -1.856 0.063 -0.106 -0.155
## flow_1 -0.070 0.073 -0.953 0.340 -0.070 -0.091
## secchi_1 -0.156 0.070 -2.227 0.026 -0.156 -0.192
## temp_1 0.312 0.221 1.416 0.157 0.312 0.121
## sside_1 0.271 0.093 2.916 0.004 0.271 0.246
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .estfish_bsmt 0.343 0.043 8.000 0.000 0.343 0.819
##
## R-Square:
## Estimate
## estfish_bsmt 0.181
labelsfarwest=createLabels(modfitFW, cnameslag)
labelswest=createLabels(modfitW, cnameslag)
labelsnorth=createLabels(modfitN, cnameslag)
labelssouth=createLabels(modfitS, cnameslag)
#FAR WEST
myLavaanPlot(model=modfitFW, labels=labelsfarwest,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
#WEST
myLavaanPlot(model=modfitW, labels=labelswest,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
#NORTH
myLavaanPlot(model=modfitN, labels=labelsnorth,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
#SOUTH
myLavaanPlot(model=modfitS, labels=labelssouth,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))